<?php
use \common\components\helpers\Fun;
use yii\helpers\Html;
use common\components\extenders\MenuManage;
use doumiaoduo\layer\LayerConfirmWidget;
use doumiaoduo\layer\LayerIframeWidget;

LayerConfirmWidget::widget();
LayerIframeWidget::widget(['button'=>"['确认操作', '取消']"]);
?>
<div class="yx-cnt-box yx-radius2">
    <div class="yx-praise-box">
        <div class="yx-search-class">
            <a href="<?=Fun::url(['orders/index'])?>">
                <button type="button"  class="btn yx-back-list yx-radius2">返回上级</button>
            </a>
            <?php if($order[0]['status'] == 0):?>
                <?=(new MenuManage(MenuManage::TOP_MENU))->detailsMenu('orders','status',true,['rel'=>'record_item_confirm','title'=>'确认订单','class' => 'btn yx-back-list yx-radius5 yx-width110 mf15','data'=>['id'=>$order[0]['id'],'status'=>1],'data-method'=>'post','data-confirm'=>'确定要确认吗']);?>
            <?php endif?>
            <?php if(($order[0]['status'] == 0 || $order[0]['status'] == 1) && $is_start == 0 ):?>
                <?=(new MenuManage(MenuManage::TOP_MENU))->detailsMenu('orders','cancel',false,['rel'=>'dialog-show-iframe','class' => 'btn yx-back-list yx-radius2 mf15','data'=>['id'=>$order[0]['id'],'name'=>'取消订单']]);?>
            <?php endif;?>
            <?php if($order[0]['pay_status'] == 0 && $order[0]['status'] != 2):?>
                <?=(new MenuManage(MenuManage::TOP_MENU))->detailsMenu('orders','paystatus',false,['rel'=>'dialog-show-iframe','class' => 'btn yx-back-list yx-bg65d1d4 yx-colorfff yx-radius2 mf15','data'=>['id'=>$order[0]['id'],'name'=>'支付']]);?>
            <?php endif?>
            <?php if(isset(\Yii::$app->user->identity)&&in_array(\Yii::$app->user->identity->role  ,['admin'])):?>
                <?php if($order[0]['pay_status'] ==0 && $order[0]['ship_status'] == 0 && $order[0]['status'] == 1):?>
                    <?=(new MenuManage(MenuManage::TOP_MENU))->detailsMenu('orders','status',true,['rel'=>'record_item_confirm','title'=>'无效订单','class' => 'btn yx-back-list yx-radius2 mf15','data'=>['id'=>$order[0]['id'],'status'=>3],'data-method'=>'post','data-confirm'=>'确定是无效订单吗']);?>
                <?php endif;?>
            <?php endif;?>
            <?php if($order[0]['ship_status'] == 2 && $order[0]['status'] == 1):?>
                <?=(new MenuManage(MenuManage::TOP_MENU))->detailsMenu('orders','status',true,['rel'=>'record_item_confirm','title'=>'完成','class' => 'btn yx-back-list yx-radius5 mf15','data'=>['id'=>$order[0]['id'],'status'=>5],'data-method'=>'post','data-confirm'=>'确定已完成吗']);?>
            <?php endif;?>
            <?php if(isset(\Yii::$app->user->identity)&&in_array(\Yii::$app->user->identity->role  ,['admin','finance'])):?>
                <?php if(in_array($order[0]['status'],[4,5]) && in_array($order[0]['pay_status'],[4,5]) && $order[0]['is_invalid'] == 0):?>
                    <?=(new MenuManage(MenuManage::TOP_MENU))->detailsMenu('orders','invalid',true,['rel'=>'record_item_confirm','class' => 'btn yx-back-list yx-radius5 mf15','data'=>['id'=>$order[0]['id']],'data-method'=>'post','data-confirm'=>'确定可购买同类型课程吗']);?>
                <?php endif;?>
            <?php endif;?>
            <div class="yx-class-box">
                <h3 class="yx-font13 yx-bold yx-pt6 yx-pb12">订单基本信息：</h3>
                <table class=" yx-course-info yx-width780">
                    <tr>
                        <td>订单号</td>
                        <td><?=$order[0]['sn']?></td>
                        <td>创建时间</td>
                        <td><?=$order[0]['created_at']?></td>
                    </tr>
                    <tr>
                        <td>付款时间</td>
                        <td><?=$order[0]['pay_time']?></td>
                        <td>发货时间</td>
                        <td><?=$order[0]['ship_time']?></td>
                    </tr>
                    <tr style="display: none">
                        <td>配送方式</td>
                        <td>顺丰快递</td>
                        <td>订单编号</td>
                        <td>SF664125475862</td>
                    </tr>
                    <tr>
                        <td>订单来源</td>
                        <td><?=$order[0]['order_source']?></td>
                        <td>支付方式</td>
                        <td><?=$order[0]['payment_name']?></td>
                    </tr>
                    <tr>
                        <td>订单状态</td>
                        <td colspan="3">
                            <span class="yx-order-zt yx-radius2"><?=$order[0]['status_name']?></span>
                            <span class="yx-order-zt yx-radius2"><?=$order[0]['pay_status_name']?></span>
                            <span class="yx-order-zt yx-radius2"><?=$order[0]['ship_status_name']?></span>
                        </td>
                    </tr>
                </table>
                <h3 class="yx-font13 yx-bold yx-pt18 yx-pb12">会员基本信息：</h3>
                <table class=" yx-course-info yx-width780">
                    <tr>
                        <td>会员名称</td>
                        <td><?=$order[0]['customer_name']?></td>
                        <td>会员卡号</td>
                        <td><?=$order[0]['card_id']?></td>
                    </tr>
                    <tr>
                        <td>联系电话</td>
                        <td><?=$order[0]['telephone']?></td>
                        <td>注册时间</td>
                        <td><?=$order[0]['customer_created_at']?></td>
                    </tr>
                    <tr style="display: none">
                        <td>收货地址</td>
                        <td colspan="3">山东省青岛崂山区市中韩街道，淘金花园小区2号楼三单元302</td>

                    </tr>

                </table>
                <h3 class="yx-font13 yx-bold yx-pt18 yx-pb12">订单商品信息：</h3>
                </a>
                <div class="docs-main">
                    <table class="tablesaw table yx-table1 yx-table3 yx-table5 table-striped with-check"  data-tablesaw-mode="swipe" data-tablesaw-minimap >
                        <thead>
                        <tr class="yx-bgd2f6ec">
                            <th class="yx-bl"></th>
                            <th>商品名称</th>
                            <th>商品分类</th>
                            <th>机构</th>
                            <th>商品单价</th>
                            <th>奖励积分</th>
                            <th>现金</th>
                            <th>奖学金</th>
                            <th>学生</th>
                            <th>已上/总课次</th>
                            <th>是否开班</th>
                            <th>状态</th>
                            <th class="yx-br">总计</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php if($orderitem):?>
                            <?php foreach($orderitem as $k=>$item):?>
                                <tr>
                                    <td><?=$k+1?></td>
                                    <td><?=Html::encode($item['name'])?></td>
                                    <td><?=Html::encode($item['type_name'])?></td>
                                    <td><?=Html::encode($item['mechanic_name'])?></td>
                                    <td><?=Html::encode($item['price'])?></td>
                                    <td><?=Html::encode($item['give_points'])?></td>
                                    <td><?=Html::encode($item['cash_money'])?></td>
                                    <td><?=Html::encode($item['scholarship_money'])?></td>
                                    <td><?=Html::encode($item['student_name'])?></td>
                                    <td><?=$item['goods_type_id'] == 1?Html::encode($item['check_number'].'/'.$item['class_count']):'--'?></td>
                                    <td><?=Html::encode($item['class_status'])?></td>
                                    <td><?=Html::encode($item['status_name'])?></td>
                                    <td><?=Html::encode($item['amount'])?></td>
                                    <td>
                                        <?=$item['view']?>
                                        <?php if(in_array($item['status'],[0,1]) && $item['is_return'] == 1 && $order[0]['status'] != 2 && $item['teach_type'] == 1):?>
                                            <?=(new MenuManage(MenuManage::TOP_MENU))->detailsMenu('orders','refund',false,['rel'=>'dialog-show-iframe','class' => 'btn yx-radius2 yx-d-card yx-bg65d1d4','data'=>['id'=>$item['id'],'name'=>'退课']]);?>
                                       <?php endif;?>
                                    </td>
                                </tr>
                            <?php endforeach;?>
                        <?php endif;?>
                        </tbody>
                    </table>
                    <p class="yx-floatr yx-color73bbef yx-font13">奖学金:<?=$order[0]['scholarship_money']?>&nbsp;现金:<?=$order[0]['account_money']?>&nbsp;订单实付金额:<?=$order[0]['final_amount']?></p>
                </div>

            </div>
        </div>
    </div>

</div>